#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
const int N = 15100;
int match[N];
bool st[N];
int h[N], ne[N], idx, e[N];
using namespace std;
int k, x1, x2;			
void add(int a, int b)
{
	e[idx] = b;
	ne[idx] = h[a];
	h[a] = idx++;
}

bool dfs(int x)
{
	for (int i = h[x]; ~i; i = ne[i]) {
		int j = e[i];
		if (!st[j]) {
			st[j] = 1;
			if (!match[j] || dfs(match[j])) {
				match[j] = x;
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	while (cin >> k,k) {	
		if (k == 0) {
			break;
		}
		cin >> x1 >> x2;
		memset(h, -1, sizeof(h));
		memset(match, 0, sizeof(match));
		while (k--) {
			int a, b;
			cin >> a >> b;
			add(a, b);
			//add(b, a);
		}
		int res = 0;
		for (int i = 1; i <= x1; i++) {
			memset(st, 0, sizeof(st));
			if (dfs(i)) {
				res++;
			}
		}
		cout << res << endl;
	}
	return 0;
}